<?php
#根路径
define('__CONFIG_PATH_ROOT',ROOT);

#相对路径
define('__CONFIG_PATH_RELATIVE_ATTACHMENT','/attachment');
define('__CONFIG_PATH_RELATIVE_ATTACHMENT_TEMP','/attachment/temp');
define('__CONFIG_PATH_RELATIVE_ATTACHMENT_EDITOR','/attachment/editor');
define('__CONFIG_PATH_RELATIVE_ATTACHMENT_NEWS','/attachment/news');
define('__CONFIG_PATH_RELATIVE_ATTACHMENT_LOGO','/attachment/logo');
define('__CONFIG_PATH_RELATIVE_ATTACHMENT_TOPIC','/attachment/topic');
define('__CONFIG_PATH_RELATIVE_ATTACHMENT_EXHIBITION','/attachment/exhibition');
define('__CONFIG_PATH_RELATIVE_ATTACHMENT_SUPPLY','/attachment/supply');
define('__CONFIG_PATH_RELATIVE_ATTACHMENT_PROCUREMENT','/attachment/procurement');
define('__CONFIG_PATH_RELATIVE_ATTACHMENT_ADVERTISEMENT','/attachment/advertisement');
define('__CONFIG_PATH_RELATIVE_ATTACHMENT_DM','/attachment/dm');
define('__CONFIG_PATH_RELATIVE_ATTACHMENT_OBSERVE','/attachment/observe');

#绝对路径
define('__CONFIG_PATH_AP_CONTENT',ROOT.'/content');
define('__CONFIG_PATH_AP_CONTENT_NEWS',ROOT.'/content/news');

#上传路径
define('__CONFIG_PATH_UPLOAD_ATTACHMENT',ROOT.__CONFIG_PATH_RELATIVE_ATTACHMENT);
define('__CONFIG_PATH_UPLOAD_ATTACHMENT_TEMP',ROOT.__CONFIG_PATH_RELATIVE_ATTACHMENT_TEMP);
define('__CONFIG_PATH_UPLOAD_ATTACHMENT_EDITOR',ROOT.__CONFIG_PATH_RELATIVE_ATTACHMENT_EDITOR);
define('__CONFIG_PATH_UPLOAD_ATTACHMENT_SUPPLY',ROOT.__CONFIG_PATH_RELATIVE_ATTACHMENT_SUPPLY);
define('__CONFIG_PATH_UPLOAD_ATTACHMENT_PROCUREMENT',ROOT.__CONFIG_PATH_RELATIVE_ATTACHMENT_PROCUREMENT);
define('__CONFIG_PATH_UPLOAD_ATTACHMENT_NEWS',ROOT.__CONFIG_PATH_RELATIVE_ATTACHMENT_NEWS);
define('__CONFIG_PATH_UPLOAD_ATTACHMENT_LOGO',ROOT.__CONFIG_PATH_RELATIVE_ATTACHMENT_LOGO);
define('__CONFIG_PATH_UPLOAD_ATTACHMENT_TOPIC',ROOT.__CONFIG_PATH_RELATIVE_ATTACHMENT_TOPIC);

/**
 * 描述：网站全局配置类，调用即可，不调用则对全局无任何预处理影响。
 * @author WangYang <3331137@qq.com>
 */
final class Config
{
    const PATH_ROOT=__CONFIG_PATH_ROOT;                                                                 //网站根目录

    /**
     * 相对路径
     */
    const PATH_RELATIVE_ATTACHMENT=__CONFIG_PATH_RELATIVE_ATTACHMENT;                                   //附件文件夹
    const PATH_RELATIVE_ATTACHMENT_EDITOR=__CONFIG_PATH_RELATIVE_ATTACHMENT_EDITOR;                     //附件文件夹-编辑器
    const PATH_RELATIVE_ATTACHMENT_NEWS=__CONFIG_PATH_RELATIVE_ATTACHMENT_NEWS;                     	//附件文件夹-新闻
    const PATH_RELATIVE_ATTACHMENT_LOGO=__CONFIG_PATH_RELATIVE_ATTACHMENT_LOGO;                   		//附件文件夹-企业LOGO	
    const PATH_RELATIVE_ATTACHMENT_EXHIBITION=__CONFIG_PATH_RELATIVE_ATTACHMENT_EXHIBITION;             //附件文件夹-行业展会
    const PATH_RELATIVE_ATTACHMENT_SUPPLY=__CONFIG_PATH_RELATIVE_ATTACHMENT_SUPPLY;                     //附件文件夹-供应信息
    const PATH_RELATIVE_ATTACHMENT_PROCUREMENT=__CONFIG_PATH_RELATIVE_ATTACHMENT_PROCUREMENT;           //附件文件夹-采购信息
    const PATH_RELATIVE_ATTACHMENT_ADVERTISEMENT=__CONFIG_PATH_RELATIVE_ATTACHMENT_ADVERTISEMENT;       //附件文件夹-广告 
    const PATH_RELATIVE_ATTACHMENT_DM=__CONFIG_PATH_RELATIVE_ATTACHMENT_DM;                             //DM杂志
    const PATH_RELATIVE_ATTACHMENT_TOPIC=__CONFIG_PATH_RELATIVE_ATTACHMENT_TOPIC;                       //附件文件夹-专题
    const PATH_RELATIVE_ATTACHMENT_OBSERVE=__CONFIG_PATH_RELATIVE_ATTACHMENT_OBSERVE;                   //附件文件夹-观察
    const PATH_RELATIVE_ATTACHMENT_TEMP=__CONFIG_PATH_RELATIVE_ATTACHMENT_TEMP;                         //附件文件夹-临时文件夹

    const PATH_RELATIVE_CONTENT='/content';                                                             //静态内容根目录
    const PATH_RELATIVE_CONTENT_NEWS='/content/news';                                                   //静态内容-新闻
    const PATH_RELATIVE_CONTENT_NEWS_DETAIL='/content/news/detail';                                     //静态内容-新闻详细
    const PATH_RELATIVE_CONTENT_EXHIBITION='/content/exhibition';                                       //静态内容-行业展会
    const PATH_RELATIVE_CONTENT_INTERVIEW='/content/interview';                                         //静态内容-访谈
    const PATH_RELATIVE_CONTENT_OBSERVE='/content/observe';                                             //静态内容-观察

    /**
     * 绝对路径
     */
    const PATH_AP_CONTENT=__CONFIG_PATH_AP_CONTENT;                                                     //静态内容文件夹
    const PATH_AP_CONTENT_NEWS=__CONFIG_PATH_AP_CONTENT_NEWS;                                           //静态内容-新闻文件夹


    /**
     * 上传设置-路径
     */
    const PATH_UPLOAD_ATTACHMENT=__CONFIG_PATH_UPLOAD_ATTACHMENT;                                       //附件文件夹
    const PATH_UPLOAD_ATTACHMENT_TEMP=__CONFIG_PATH_UPLOAD_ATTACHMENT_TEMP;                             //附件文件夹-临时文件夹
    const PATH_UPLOAD_ATTACHMENT_EDITOR=__CONFIG_PATH_UPLOAD_ATTACHMENT_EDITOR;                         //附件文件夹-编辑器
    const PATH_UPLOAD_ATTACHMENT_SUPPLY=__CONFIG_PATH_UPLOAD_ATTACHMENT_SUPPLY;                         //附件文件夹-供应信息
    const PATH_UPLOAD_ATTACHMENT_PROCUREMENT=__CONFIG_PATH_UPLOAD_ATTACHMENT_PROCUREMENT;               //附件文件夹-采购信息    
    const PATH_UPLOAD_ATTACHMENT_NEWS=__CONFIG_PATH_UPLOAD_ATTACHMENT_NEWS;                             //附件文件夹-新闻
    const PATH_UPLOAD_ATTACHMENT_TOPIC=__CONFIG_PATH_UPLOAD_ATTACHMENT_TOPIC;                           //附件文件夹-专题

    /**
     * 上传设置-大小
     */
    const UPLOAD_ATTACHMENT_SIZE_IMAGE=204800;                                                          //文件大小-图片:204800=200K
    const UPLOAD_ATTACHMENT_SIZE_FILE=10485760;                                                         //文件大小-文件：10485760=10M
    const UPLOAD_ATTACHMENT_EXT_IMAGE='gif,jpg,png,bmp';                                                //文件扩展名-图片
    const UPLOAD_ATTACHMENT_EXT_FILE='pdf,txt,doc,docx,xls,xlsx';                                       //文件扩展名-文件

    /**
     * 描述：EPDO数据库连接配配置信息，可以根据需要添加多个需要的数据库资源。
     * @access public
     * @param  string optional default:Default $name
     * @return array
     * @static
     */
    public static function DBServers($name='Default')
    {
        switch(strtolower($name))
        {
              case 'default':
                    return array
                    (
                          'Name'=>'Default',
                          'DSN'=>'mysql:host=localhost;port=60841;dbname=shipinall;',
                          'User'=>'root',
                          'Password'=>'/;p09ol.,ki8__',
                          'Options'=>array
                          (
                                PDO::MYSQL_ATTR_INIT_COMMAND =>"SET character_set_connection=UTF8,character_set_results=UTF8,character_set_client=binary"
                          ),
                          'Attribute'=>array
                          (
                                PDO::ATTR_ERRMODE=>PDO::ERRMODE_EXCEPTION
                          )
                    );
              break;
              default:
                    throw new Exception('class.Config.DBServers：不存在名称为"'.$name.'"的数据库资源的配置数组。');
              break;
        }
    }

    public static function View()
    {
        return array(
            'error_reporting'=>E_ALL,                                           //错误级别
            'debugging'=>FALSE,                                                  //调试开关
            'caching'=>FALSE,                                                    //缓存设置
            'allow_php_tag'=>TRUE,                                              //php标识
            'template_dir'=>self::PATH_ROOT.'/template/templates',              //模板目录
            'compile_dir'=>self::PATH_ROOT.'/template/templates_c',             //编译目录
            'config_dir'=>self::PATH_ROOT.'/template/configs',                  //配置目录
            'cache_dir'=>self::PATH_ROOT.'/template/cache',                     //缓存目录
            'left_delimiter'=>'<!--[',                                             //设置html代码中使用的边界符号左
            'right_delimiter'=>']-->'                                             //设置html代码中使用的边界符号右
        );
    }

    /**
    * 描述：静态化配置。
    * @static
    * @access public
    * @return array
    */
    public static function Staticize()
    {
        return array(
              'ContentDirectory'=>self::PATH_ROOT.'/content'
        );
    }

    /**
    * 描述：发送邮件配置。
    * @static
    * @access public
    * @return array
    */
    public static function Email()
    {
        return array(
            'Server'=>'smtp.dlcbpt.com',
            'Server_Port'=>25,
            'Username'=>'web@dlcbpt.com',
            'Password'=>'shipinall123'
        );
    }
}
?>